var serverurl="http://127.0.0.1:8081"
var code;
function Code(){
    var xmlhttp;
    if (window.XMLHttpRequest) {
        // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp = new XMLHttpRequest();
    } else {
        // IE6, IE5 浏览器执行代码
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
            var res=JSON.parse(xmlhttp.responseText);
            console.log('验证码:'+res[0]);
            code=res[0];
            document.getElementById('ccap').src='data:img/jpg;base64,'+res[1];
        }
    }
    xmlhttp.open("get", serverurl + "/ccap", true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.send("");
}
Code();